package com.muse.map;

import com.muse.util.ListNode;

public class MapTest {
    private ListNode node;
    public static void main(String[] args) {
        MapTest mapTest = new MapTest();
        mapTest.initNode();
        mapTest.test();
    }

    public void initNode() {
        ListNode node3 = new ListNode(3, null);
        ListNode node2 = new ListNode(2, node3);
        ListNode node1 = new ListNode(1, node2);
        node = node1;
    }

    public void test() {
        new Thread(() -> {
            try {
                ListNode next = node.next;
                Thread.sleep(1000);
                System.out.println(node.val); // 1
                System.out.println(next.val); // 2
                Thread.sleep(1000);
                System.out.println(next.next.val); // 1
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }).start();

        new Thread(() -> {
            ListNode next = node.next;
            ListNode nextn = node.next.next;
            nextn.next = next;
            next.next = node;
            node.next = null;
            System.out.println("-----------");
            System.out.println(nextn.val);
            System.out.println(nextn.next.val);
            System.out.println(nextn.next.next.val);
            System.out.println("-----------");
        }).start();
    }
}
